import { ref } from "vue";

const panOnDrag = ref(false);

// 按下Ctrl键时触发拖拽
const onDKeyDown = (event: KeyboardEvent) => {
  if (event.key=='d') {  // 检测Ctrl键是否按下
    panOnDrag.value = true;  // 启用拖拽
  }
};

// 松开Ctrl键时禁用拖拽
const onDKeyUp = (event: KeyboardEvent) => {
  if (event.key=='d') {  // 检测Ctrl键是否松开
    panOnDrag.value = false;  // 禁用拖拽
  }
};

export const useDDrag = () => {
  return { panOnDrag, onDKeyDown, onDKeyUp };
};
